package pos.gengshen.com.gspos.utils;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import pos.gengshen.com.gspos.pojo.Order;
import pos.gengshen.com.gspos.pojo.PayRecord;
import pos.gengshen.com.gspos.pojo.Shift;
import pos.gengshen.com.gspos.pojo.ShiftDetail;

/**
 * Created by Administrator on 2018/7/13/013.
 * 打印工具类
 */

public class PrintUtils {

    public static String getShiftDetailString(Shift shift, List<Order> orderList, List<PayRecord> payList, List<ShiftDetail> detailList){
        SimpleDateFormat sf = new SimpleDateFormat("HH:mm:ss");

        String str = "\n          交班统计       "
                + "\n-------------------------------"
                + "\n值 班 员："+shift.getOperator()
                +"\n班    号："+shift.getShiftName()
                + "\n上班时间："+DateTimeUtilT.dateTime(shift.getStratDate())
                + "\n门店名称："+shift.getShopName()
                +"\n实际收款："+shift.getIncome()/100.0
                +"\n订单总额："+shift.getTotalMoney()/100.0
                +"\n优惠总额："+shift.getDiscount()/100.0
                +"\n加油订单数："+shift.getPayOrderNum()
                +"\n退款金额："+shift.getRefund()/100.0
                +"\n退款笔数："+shift.getRefundNum()
                +"\n送出积分："+shift.getTotalIntagral()
                +"\n";


        if(detailList != null && detailList.size() > 0){

            str =str+ "\n 一键加油";
            str = str+ "\n-------------------------------";
            str = str+ "\n油品   实收    优惠     状态";
            for(ShiftDetail detail:detailList){
                String state = "";
                if(detail.getState() && !detail.getRefund()){
                    state = "支付成功";
                }else if(detail.getState() && detail.getRefund()){
                    state = "退款"+detail.getRefnndMoney()/100.0;
                }
                str = str +"\n"+detail.getOilCode()+"    "+detail.getPayMoney()/100.0+"    "+detail.getDiscount()/100.0+"    "+state;
                str = str+"\n";
            }
        }

        if(payList != null && payList.size() >0){
            str = str +"\n油卡充值";
            str = str +"\n-------------------------------";
            str = str + "\n会员    卡号     金额      状态";
            for(PayRecord pay:payList){
                String state ="";
                if(pay.getIsPay() && !pay.getIsRecode()){
                    state = "异常";
                }else if(pay.getIsPay() && pay.getIsRecode()){
                    state = "成功";
                }
                str = str + "\n"+getNumberString(pay.getNick(),4)+" "+pay.getCard()+"  "+pay.getPayMoney()/100.0+"  "+state;
                str = str+"\n";
            }
        }

        if(orderList != null && orderList.size()>0){
            str = str +"\n礼品核销";
            str = str +"\n-------------------------------";
            str = str + "\n会员    消费积分       兑换时间";
            for(Order order:orderList){
                str = str +"\n"+getNumberString(order.getNick(),4)+"    "+order.getPayMoney()+"        "+sf.format(order.getExchangeDate());
            }
        }

        return str;
    }



    public static String getNumberString(String str,int num){

        if(str.toCharArray().length > num){
            str = str.substring(0,num);
            str=str+"..";
        }else if(str.toCharArray().length < num){
            int i =num - str.toCharArray().length;







        }
        return str;
    }



}
